import { useEffect, useRef, useState } from "react";



export default function <T = any>(initValue: T) {
    const [value, setValue] = useState(initValue)
    const ref = useRef(initValue)
    useEffect(() => {
        ref.current = value;
    }, [value])
    return [value, setValue,ref] as const 
}